package com.zengqingfa.examples.mybatisplus.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @fileName: ThreadPoolService
 * @author: zengqf3
 * @date: 2021-6-30 13:41
 * @description:
 */
@Configuration
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor
                (8, 16, 60,
                        TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
                        new ThreadFactoryBuilder().setNameFormat("mdc-test-pool-%d")
                                .build());
        return threadPoolExecutor;
    }
}
